package com.study.springsession.controller;

import com.study.springsession.controller.vo.UserVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class TestController {

    @GetMapping("/test")
    public String test(HttpSession session){
//        session.setAttribute("name", "wuyu");
        UserVo u = new UserVo();
        u.setName("wuyu");
        u.setAge(30);
        session.setAttribute("user", u);
        return "登陆成功";
    }

    @GetMapping("/test1")
    public UserVo test1(HttpSession session){
//        Object name = session.getAttribute("name");
        UserVo u = (UserVo)session.getAttribute("user");
        return u;
    }
}
